//引入express模块
const express=require('express');
//引入连接池模块
const pool=require('../pool.js');
//console.log(pool);
//创建路由器对象
const r=express.Router();
//查找本周最热的接口
//接口地址:http://127.0.0.1:3000/v1/this_weeks/this_week
//请求方式 :get
r.get('/this_week',(req,res,next)=>{
  //获取路由传递的参数
  var obj=req.params;
  console.log(obj);
  //执行sql命令
  pool.query('select * from this_week',(err,result)=>{
    if(err){
      next(err);
      return;
    }
    console.log(result);
    if(result.length===0){
      res.send({code:501,msg:'查找失败'});
    }else{
      res.send({code:200,msg:'查找成功',bzzr:result})
    }
  })
})
module.exports=r;